<?php
/***********************************************************************

  Copyright (C) 2002-2008  PunBB

  This file is part of PunBB.

  PunBB is free software; you can redistribute it and/or modify it
  under the terms of the GNU General Public License as published
  by the Free Software Foundation; either version 2 of the License,
  or (at your option) any later version.

  PunBB is distributed in the hope that it will be useful, but
  WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  MA  02111-1307  USA

************************************************************************/

/*TODO: use language package instead of writing text in this file */
/*TODO: user premission */

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/topic.php';
$forumid = 4;
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $lang_common['lang_encoding'] ?>" />
<title>&#25104;&#38271;&#26085;&#24535;</title>
<link rel="stylesheet" type="text/css" href="style/<?php echo $pun_user['style'].'.css' ?>" />
</head>
<body>
<div id="punwrap">
<div id="punviewtopic" class="pun">
<h1>日志</h1>
<p>
<?php
$sql = 'SELECT id, poster, subject, posted, last_post, last_post_id, last_poster, num_views, num_replies, closed, sticky, moved_to FROM '.$db->prefix.'topics WHERE forum_id='.$forumid.' ORDER BY posted DESC LIMIT 10';

$result = $db->query($sql) or error('Unable to fetch topic list', __FILE__, __LINE__, $db->error());


// If there are topics in this forum.
if ($db->num_rows($result))
{
	while ($cur_topic = $db->fetch_assoc($result))
	{
        $topicid = $cur_topic['id'];
        echo '<div class="blockpost rowodd firstpost">';
        $subject = '<h2><span><span class="byuser conr">'.$lang_common['by'].'&nbsp;'.pun_htmlspecialchars($cur_topic['poster']).'&nbsp;'.format_time($cur_topic['posted']).'</span><a href="viewtopic.php?id='.$topicid.'">'.pun_htmlspecialchars($cur_topic['subject']).'</a></span></h2>';
        echo $subject."\n";

        $result_post = $db->query('SELECT message, hide_smilies FROM '.$db->prefix.'posts WHERE topic_id='.$topicid.' ORDER BY id LIMIT 1') or error('Unable to fetch post info', __FILE__, __LINE__, $db->error());
        while ($cur_post = $db->fetch_assoc($result_post))
        {
            echo '<div class="box"><div class="inbox">';
            $cur_post['message'] = parse_message($cur_post['message'], $cur_post['hide_smilies']);
            $message = '<div name="convert" class="postmsg">'.$cur_post['message'].'</div>';
            echo $message."\n";
            echo '<div class="postlink conr"><a href="post.php?tid='.$topicid.'">'.$lang_topic['Post reply'].'</a></div>';
            echo '</div></div>';
        }
        echo '</div>';
        echo '<br />';
    }
}

?>
</p>
</div>
</div>
</body>
</html>

